generators.js ➔ generateActions   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 2
1
/* eslint-disable no-unused-vars */
2
import fatum from 'fatum';
3
4
const METHODS = [ 'GET', 'PATCH', 'POST', 'PUT', 'OPTIONS', 'HEAD', 'DELETE' ];
5
const GROUPS = [ 'users', 'posts', 'externals', 'messages' ];
6
const TITLES = {
7
    users     : [ 'create user', 'update user', 'delete user', 'show user' ],
8
    posts     : [ 'create post', 'update post', 'delete post', 'show post' ],
9
    messages  : [ 'create message', 'update message', 'delete message', 'show message' ],
10
    externals : [ 'heath', 'info', 'help', 'contacts' ]
11
};
12
13
export function actionGenerate() {
14
    const method = fatum.pick(METHODS);
0 ignored issues
show
Unused Code introduced by
The constant method seems to be never used. Consider removing it.
Loading history...
15
    const url = fatum.domain();
0 ignored issues
show
Unused Code introduced by
The constant url seems to be never used. Consider removing it.
Loading history...
16
    const group = fatum.pick(GROUPS);
17
    const title = fatum.pick(TITLES[group]);
0 ignored issues
show
Unused Code introduced by
The constant title seems to be never used. Consider removing it.
Loading history...
18
}
19
20
export function generateActions(count = 100, options = {}) {
21
    return Array.from({ length: count }).map(() => actionGenerate());
22
}
23
24
export function AxiosCollection(baseUrl) {}
0 ignored issues
show
Unused Code introduced by
The parameter baseUrl is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
25
26
export function generateAxiosRequest(baseUrl, { method, query, path } = {}) {
27
    return {
28
        method : method.toUpperCase(),
29
        url    : baseUrl + path
30
    };
31
}
32